/**
 * ------------------------------------------------------------------
 * 工具库
 * @author oyjt
 * @date 2015-7-6
 * ------------------------------------------------------------------
 */
/*var iphoneDownloadURL = "http://histudio-supermama-image.oss-cn-hangzhou.aliyuncs.com/package%2Fsupermommy_1.0_201508071904.apk",
  androidDownloadURL = "http://histudio-supermama-image.oss-cn-hangzhou.aliyuncs.com/package%2Fsupermommy_1.0_201508071904.apk";*/
/**
 * 通用拦截
 * @param data 返回结果
 * @return {Boolean}
 */
function checkCode(data){
	var sta = false;
	switch(parseInt(data.code)){
		case 0:break;
		default:alert(data.info); sta = true;break;
	}
	return sta;
}

/**
 * 时间戳转换
 * @param  nS 时间戳
 * @return {String}
 */
function getLocalTime(nS) {
	var dt = new Date(nS),
		year = dt.getFullYear(),
		month = dt.getMonth()+1,
		day = dt.getDate();
	return year+"-"+month+"-"+day;
}
/**
 * 时间戳转换
 * @param  nS 时间戳
 * @return {String}
 */
function getLocalTimemonthday(nS) {
	var dt = new Date(nS),
		year = dt.getFullYear(),
		month = dt.getMonth()+1,
		day = dt.getDate();
	return month+"-"+day;
}
/**
 * 判断是否微信登录
 * @return {Boolean}
 */
function isWeixin(){  
    var ua = navigator.userAgent.toLowerCase();  
    return ua.match(/microMessenger/i)=="micromessenger";
}

/**
 * 判断是否是Android设备
 * @return {Boolean}
 */
function isAndroid(){
  var ua = navigator.userAgent;
  return ua.indexOf('Mozilla/5.0') > -1 && ua.indexOf('Android ') > -1 && ua.indexOf('AppleWebKit') > -1 && ua.indexOf('Chrome') === -1;
}

/**
 * 判断是否是IOS设备
 * @return {Boolean}
 */
function isIOS(){
  var ua = navigator.userAgent;
  return !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
}

/**
 * 获取URL参数
 */
function URLParams() {
	var url = location.search,
		theRequest = {};
	if (url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		for (var i = 0; i < strs.length; i++) {
			theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
		}
	}
	return theRequest;
}